package com.example.kcp.enums;

import lombok.Getter;

/**
 * @author "陈凯航"
 * @date 2024/9/24
 * @mail "mengxingcn@aliyun.com"
 */
@Getter
public enum ExecutionCode {
    SUCCESS((byte) 0x00),
    ERROR((byte) 0x01),
    SERVICE_CODE_INCORRECT((byte) 0x02),
    COMMAND_CODE_INCORRECT((byte) 0x03),
    PACKET_HEADER_INCORRECT((byte) 0x04),
    NAVIGATION_STATUS_CONFLICTS((byte) 0x80);

    private final byte value;

    ExecutionCode(byte value) {
        this.value = value;
    }

    public static ExecutionCode ofByte(byte b) {
        for (ExecutionCode value : ExecutionCode.values()) {
            if (value.getValue() == b) return value;
        }
        throw new IllegalArgumentException("invalid Parameter Exception byte: "+b);
    }

}
